package xio.ccf_201503;
/*
 * ccf 201503-3 节日 90分
 * 思路：计算y年节日月份的1号距1850年1月1号有多少天，并据此计算出该月1号是星期几，然后算出节日第一周是几号
 */

import java.util.Scanner;

public class Holiday {
   static int[] daysOfMonth = {31,28,31,30,31,30,31,31,30,31,30,31};
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int month = scanner.nextInt();  //节日月份
		int week = scanner.nextInt();  //节日是第几周
		int weekday = scanner.nextInt();   //节日是星期几
		int yearSt = scanner.nextInt(); //开始年份
		int yearEd = scanner.nextInt(); //结束年份

		
		
		int daysAll =0; //记录1850年到某一年分（yearSt 至 yearEd）1月1号的总天数

		for(int y = 1850;y<yearSt;y++) {
			daysAll+=getDaysCount(y);
		}

		int daysMonths = 0; //记录1月到节日月份1号的总天数
		for (int i = 0; i < month-1; i++) {
			daysMonths+=daysOfMonth[i];
		}
		
		
		int curYearDays= 0; //当前年份的节日月份1号距1850年的总天数
		int resultDay = 0;
		
		for(int y=yearSt;y<=yearEd;y++) {
			if (isLeap(y)) {
				curYearDays = daysAll+daysMonths+1;
			}else {
				curYearDays = daysAll+daysMonths;
			}
			
			int wd = (curYearDays+2)%7; //该月1号是星期几
			if (wd == 0) {
				wd = 7;
			}
//			System.out.println(y+" month:"+month+" weekday:"+wd);
			if (wd<=weekday) {
				resultDay =(weekday-wd+1)+(week-1)*7;
			}else {
				resultDay = (7-wd+weekday+1)+(week-1)*7;
			}
			if (resultDay <= getMonthDays(y, month)) {
				System.out.println(y+"/"+format(month)+"/"+format(resultDay));
			}else {
				System.out.println("none");
			}

			daysAll +=getDaysCount(y);
		}
	}

	/*
	输出要求 个位数显示'0x'
	 */
	private static String format(int m) {
		if (m <10) {
			return "0"+m;
		}
		return m+"";
	}

	/*
	一个月的天数
	 */
	private static int getMonthDays(int year,int month) {
		if (month == 2) {
			if (isLeap(year)) {
				return 29;
			}else {
				return 28;
			}
		}
		return daysOfMonth[month-1];
		
	}

	/*
	一年总天数
	 */
	private static int getDaysCount(int year) {
		if (isLeap(year)) {
			return 366;
		}else {
			return 365;
		}
	}

	/*
	是否是闰年
	 */
	private static boolean isLeap(int year) {
		return  (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
	}
}
